package com.ax.center.controller;

import com.ax.center.annotation.Logging;
import com.ax.center.dto.ApiResponse;
import com.ax.center.entity.Role;
import com.ax.center.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zy
 * @date 2023/7/6 14:58
 */
@RestController
@RequestMapping(value = "roleController")
@Api(tags = "角色服务")
@CrossOrigin(origins = "http://localhost:5173")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @PostMapping("/无效的请求")
    public void test(@RequestBody Role role){
        return;
    }

    @Logging(description = "删除角色和其对应的权限")
    @GetMapping(value = "/deleteById/{id}")
    @ApiOperation("删除角色和其对应的权限")
    public ApiResponse deleteById(@PathVariable("id")Long id){
      return   roleService.deleteRole(id);
    }

    @Logging(description = "添加角色")
    @PostMapping(value = "/addRole")
    @ApiOperation("添加角色")
    public ApiResponse addRole(@RequestBody Role role){
        return  roleService.addRole(role);
    }

    @Logging(description = "查询所有角色")
    @GetMapping(value = "/queryAll")
    @ApiOperation("查询所有角色")
    public ApiResponse query(){
        return  roleService.queryAll();
    }


}
